import { defineStore } from 'pinia'
import type { LoadingState } from './interface'

export const useLoadingStore = defineStore('loading', {
    state: (): LoadingState => {
        return {
            open: false,
        }
    },
    actions: {
        // 打开全局loading
        loadingOpen() {
            this.open = true
        },
        // 关闭全局loading
        loadingClose() {
            this.open = false
        },
        start() {
            this.loadingOpen()
        },
        exit() {
            this.loadingClose()
        },
    },
})
